package com.hdax.dmw.item.config.globalexception;

import com.hdax.dmw.exceptions.user.LoginException;
import com.hdax.dmw.exceptions.user.TokenException;
import com.hdax.dmw.utils.Result;
import com.hdax.dmw.utils.ResultGenerator;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = TokenException.class)
    public Result tokenExceptionHandler(TokenException e){
        return ResultGenerator.genErrorResult(e);
    }

    @ExceptionHandler(value = ExpiredJwtException.class)
    public Result jwtExceptionHandler(ExpiredJwtException e){
        return ResultGenerator.genErrorResult("9999","token过期");
    }

}
